home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / msqc25t1 / windemo.c < prev    next >
C/C++ Source or Header  |  1990-09-23  |  3KB  |  85 lines

  1. /* windemo.c: Shows windowing and screen save/restore. */
  2.  
  3. #include <conio.h>
  4. #include <graph.h>
  5. #include "textscrn.h"
  6.  
  7. /* DEFINE TYPES */
  8. typedef struct {                                /* window descriptor */
  9.     int     t, l, b, r;
  10.     char    image [800];
  11. } WINDESCR;
  12.  
  13. /* GLOBAL WINDOW DESCRIPTORS */
  14. WINDESCR w [] = {
  15.     { 10, 10, 20, 20},
  16.     {  5, 40, 15, 70},
  17.     { 12, 22, 17, 55}
  18. };
  19.  
  20. /* LOCAL FUNCTION PROTOTYPES */
  21. void prompt (char*);
  22. int space (int, int, int, int);
  23. void fillwin (int);
  24. /*----------------------------*/
  25.  
  26. main()
  27. {
  28.     int n;
  29.  
  30.         _outtextf ("This is at row %d, column %d", n, n);
  31.     _clearscreen (_GCLEARSCREEN);           /* clear the screen */
  32.         _outtextf ("This is at row %d, column %d", n, n);
  33.     _settextcolor (BROWN);
  34.     for (n = 1; n < 23; n++) {  /* write some backgrnd text */
  35.         _settextposition (n, n);
  36.         _outtextf ("This is at row %d, column %d", n, n);
  37.     }
  38.  
  39.     for (n = 0; n < 3; n++) {           /* loop for three windows */
  40.         prompt ("Press any key for next window");
  41.         _savescrn (0);                  /* save screen */
  42.         _settextwindow (w[n].t, w[n].l,
  43.                         w[n].b, w[n].r);
  44.         fillwin (n);                        /* fill window */
  45.     }
  46.  
  47.     for (n = 2; n >= 0; n--) {              /* step back erasing */
  48.         prompt ("Press any key to erase last window");
  49.         _restscrn (0);                      /* LIFO restore */
  50.     }
  51.  
  52.     prompt ("Press any key to quit");
  53.     _settextcolor (LTGRAY);
  54.     _clearscreen (_GCLEARSCREEN);           /* clear the screen */
  55. } /*---------------------------------*/
  56.  
  57. void prompt (char *mssg)
  58.  
  59.     /* Write prompt message at bottom of scrn and wait */
  60.  
  61. {
  62.     _settextwindow (1, 1, 25, 80);      /* use whole screen */
  63.     _settextposition (24, 1);           /* go to prompt line */
  64.     _settextcolor (WHITE);
  65.     _setbkcolor (0L);
  66.     _cleareol();                        /* clear line */
  67.     _outtext (mssg);                    /* write message */
  68.     getch();                        /* hold until key pressed */
  69. } /*---------------------------------*/
  70.  
  71. void fillwin (int number)
  72.  
  73.     /* Fill active window with scrolling text */
  74.  
  75. {
  76.     int i, c;
  77.  
  78.     _clearscreen (_GWINDOW);           /* clear active window */
  79.     _settextcolor (number + 1);         /* blue, green cyan */
  80.     for (i=0; i<30; i++)
  81.         for (c = 33; c<127; c++)        /* print all chars */
  82.             _outch (c);
  83. } /*---------------------------------*/
  84.  
  85.